/*
 * container.h
 *
 *  Created on: 11.03.2012
 *      Author: ignacio
 */

#ifndef CONTAINER_H_
#define CONTAINER_H_

#include <vector>

namespace neurignacio{
	template <typename Type> class BaseContainer : public std::vector<Type>		// Definition for the basic container type (i.e. vector)
	{
	public:
		// Inherites everything from vector<Type>
		void push_back_as_Copy(Type item) {Type copy(item); push_back(item);}
	};

	template <typename Type> class BasePointerContainer : public BaseContainer<Type* >		// Definition for the basic container type with pointers (i.e. vector)
	{
	public:
		// Inherites everything from vector<Type>
	//	void prueba(Type* item) {push_back(boost::shared_ptr<Type>(item));}
	//	void push_back(Type* pointer) {vector<SmartPointer<Type> >::push_back(pointer);}
	//	void push_back_as_Copy(Type& item) {SmartPointer<Type> copy(new Type(item)); push_back(copy);} // check exceptions!!!
		template <typename TypeSource> void copy(BasePointerContainer<TypeSource>& source);
	};

	template <typename Type>
	template <typename TypeSource> void BasePointerContainer<Type>::copy(BasePointerContainer<TypeSource>& source)
	{
		unsigned int n=source.size();
		this->resize(n);
		for (unsigned int i=0; i<n; ++i)
			(*this)[i]=static_cast<Type*>(source[i]);
	}

} // end namespace neurignacio

#endif /* CONTAINER_H_ */
